window.onload = function() {
    $(".shop-cart2").on('click', function () {
        htmlobj = $.ajax({
            dataType:"json",
            type:"GET",
            url:"/showCart",
            error:function () {
                console.log("error");
            },
            success:function(resp){
                console.log(resp);
                $("#cart-main ul").empty();
                var cartLines = resp.cartLines;
                for(var i = 0;i<cartLines.length;i++){
                    $("#cart-main ul").append($("<li/>")
                        .append($("<img/>").attr("src","images/xtra/3.jpg").attr("alt",""))
                        .append($("<div/>").attr("class","description"))
                            .append($("<div/>").attr("class","clearfix")));
                    $(".description").append($("<div/>").attr("class","closeit").text("X"))
                        .append($("<a/>").attr("href","./product_single.html").text(cartLines[i].name))
                        .append($("<div/>").attr("class","position"));
                    $(".position").append($("<p/>").append($("<span/>").attr("class","currency")
                        .append($("<span/>").text("￥")).append($("<span/>").text(cartLines[i].price)).append($("<span/>").attr("class","sign").text("x")))
                        .append($("<input/>").attr("value",cartLines[i].quanlity)))
                }
                $("#cart-main").slideToggle(function () {
                });
            }
        });
    });
}